package com.game.framework;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;


/// 核心管理器--用于统一管理Manager（初始化与关闭）
public class CoreManager implements IManager {

	@Getter
    private static final CoreManager instance = new CoreManager();
	private final List<IManager> allManagers = new ArrayList<>();

    /**
	 * 初始化每一个manager
	 */
	@Override
	public void init() {
		for (IManager m : allManagers) {
			m.init();
		}
	}

	@Override
	public void shutdown() {
		int size = allManagers.size();
		for (int i = size - 1; i >= 0; --i) {
			allManagers.get(i).shutdown();
		}
	}

	public void registerManager(IManager m) {
		allManagers.add(m);
	}
}
